local skel = fk.CreateSkill {
  name = "efengqi__wulie",
  tags = {Skill.Lord},
}

Fk:loadTranslationTable{
  ["efengqi__wulie"] = "武烈",
  [":efengqi__wulie"] = "主公技，当吴势力角色杀死一名角色或死亡后，你可令任意名角色各摸X张牌（X为你发动过此技能的次数）。",
  ["@efengqi__wulie"] = "武烈",
  ["#efengqi__wulie-choose"] = "武烈：你可选择任意名角色，令这些角色各摸 %arg 张牌",

  ["$efengqi__wulie1"] = "义定四野，武匡海内。",
  ["$efengqi__wulie2"] = "江东男儿，皆胸怀匡扶天下之志。",
}

skel:addEffect(fk.Deathed, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and ((data.killer and data.killer.kingdom == "wu") or target.kingdom == "wu")
  end,
  trigger_times = function (self, event, target, player, data)
    local n = 0
    if data.killer and data.killer.kingdom == "wu" then
      n = n + 1
    end
    if target.kingdom == "wu" then
      n = n + 1
    end
    return n
  end,
  on_cost = function(self, event, target, player, data)
    local tos = player.room:askToChoosePlayers(player, {
      min_num = 1, max_num = 999, targets = player.room.alive_players, skill_name = skel.name,
      prompt = "#efengqi__wulie-choose:::" .. player:usedSkillTimes(self.name, Player.HistoryGame) + 1,
    })
    if #tos > 0 then
      player.room:sortByAction(tos)
      event:setCostData(self, {tos = tos})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local x = player:usedSkillTimes(self.name, Player.HistoryGame)
    local tos = event:getCostData(self).tos
    for _, to in ipairs(tos) do
      if not to.dead then
        to:drawCards(x, skel.name)
      end
    end
  end,
})

return skel
